<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
	
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/xadmin/css/font.css">
	<link rel="stylesheet" href="/static/xadmin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/static/xadmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/xadmin/js/xadmin.js"></script>
	
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>个人信息</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">&#xe669;</i></a>
    </div>
    <div class="x-body">
    <div class="layui-col-md11">
        <form class="layui-form layui-form-pane" action="" lay-filter="UpdateUserInfo">
		<div class="layui-form-item" style="margin-bottom:2px">
            <div class="layui-inline">
                <label class="layui-form-label">ID</label>
                    <div class="layui-input-inline" style="width: 213px;">
                        <input type="text" name="Id" autocomplete="off" readonly="true" placeholder="" class="layui-input">
                    </div>
            </div>
		</div>	
						
		<div class="layui-form-item" style="margin-bottom:2px">
            <div class="layui-inline">
                <label class="layui-form-label">用户名</label>
                    <div class="layui-input-inline" style="width: 213px;">
                        <input type="text" name="Username" autocomplete="off" readonly="true" lay-verify="nickname" placeholder="" class="layui-input">
                    </div>
	            <div class="layui-form-mid" style="color: red;">*</div>
            </div>
		</div>	
		<div class="layui-form-item" style="margin-bottom:2px">
		    <div class="layui-inline">
		      	<label class="layui-form-label">昵称</label>
		      		<div class="layui-input-inline" style="width: 213px;">
		        		<input type="text" name="Nickname" placeholder="" lay-verify="nickname" autocomplete="off"  class="layui-input">
		      		</div>
		    </div>   
		</div>	
		<div class="layui-form-item" style="margin-bottom:2px">	
   			<div class="layui-inline">
    			<label class="layui-form-label">邮箱</label>
    				<div class="layui-input-inline" style="width: 213px;">
      					<input type="text" name="Email" placeholder="" autocomplete="off" lay-verify="email" class="layui-input">
    				</div>
   			</div>
		</div>
<!--		
		<div class="layui-form-item" style="margin-bottom:2px">
   			<div class="layui-inline">
    			<label class="layui-form-label">密码</label>
   					<div class="layui-input-inline" style="width: 213px;">
      					<input type="password" id="L_pass" name="Password" placeholder="" lay-verify="pass" autocomplete="off" class="layui-input">
    				</div>
				<div class="layui-form-mid" style="color: red;">*</div>
   			</div>
		</div>	
		<div class="layui-form-item" style="margin-bottom:2px">			
   			<div class="layui-inline">
    			<label class="layui-form-label">确认密码</label>
    				<div class="layui-input-inline" style="width: 213px;">
      					<input type="password" id="L_repass" name="Repassword" placeholder="" lay-verify="repass" autocomplete="off" class="layui-input">
    				</div>
				<div class="layui-form-mid" style="color: red;">*</div>
   			</div>   
		</div>	
-->
		<div class="layui-form-item" style="margin-bottom:2px">  
    		<div class="layui-inline">
      			<label class="layui-form-label">备注</label>
      				<div class="layui-input-inline" style="width: 213px;">
        				<input type="text" name="Remark" autocomplete="off" class="layui-input">
      				</div>
    		</div>   
        </div>
        <div class="layui-form-item">
          <button class="layui-btn" lay-submit="" lay-filter="UpdateUserSubmit">更改</button>
        </div>
      </form>
    </div>

</div>

    <script>	
      layui.use(['form','table'], function(){
		var table = layui.table;
        var form=layui.form;		
			$.ajax({
			   url: "/public/myinfo",
			   type: "GET",
			   headers:{'X-Requested-With':'XMLHttpRequest'},
			   success: function (resp) {
				  form.val('UpdateUserInfo', {
				    "Id": resp.data.Id
				    ,"Username": resp.data.Username
				    ,"Nickname": resp.data.Nickname
				    ,"Email": resp.data.Email
				   // ,"Password": resp.data.Password
				    ,"Remark": resp.data.Remark
				   // ,"Status": resp.data.Status
				  })
				}
		    });	
		
        //自定义验证规则
		form.verify({
			nickname: function(value){
			  if(value.length < 5){
				return '至少5个字符且不能有特殊字符';
			  }
			}
			,pass: [/(.+){6,12}$/, '密码必须6到12位']
			,repass: function(value){
				if($('#L_pass').val()!=$('#L_repass').val()){
					return '两次密码不一致';
				}
			}
			,email: [/^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$|^1[3|4|5|7|8]\d{9}$/, '邮箱格式不对']
		});		

        form.on('submit(UpdateUserSubmit)', function(datas){
			layer.confirm('确定更改?', {icon: 3, title:'提示',yes: function(index){
                     $.ajax({
                       url: "/rbac/user/UpdateUser",
                       type: "post",
                       data: datas.field,
                       dataType: "json",
                       success: function (resp) {
                                 if(resp.status){
                                    layer.msg('修改成功', {icon: 1});
                                 }else{
                                    layer.msg('修改失败',{icon:2});
                                 }
                        }
                   });		  	  
               },
                cancel: function(index, layero){ 
                    layer.close(index);
		            console.log("不操作");
                } 
            }); 		   
	      	return false; 	
		});		
 });  
    </script>
  </body>

</html>